<template>
	<view>
		<cu-custom :key="'header'+headerKey" bgColor="bg-gradual-blue-light"  :isBack="true" backText="返回" title="家庭成员信息"></cu-custom>
		<view class="cu-card article no-card" v-for="(item,index) in memberList" :key="index" :info="item" >
			<view class="cu-item shadow bg-white" style="margin-bottom: 20rpx;display: flex;align-items: center;justify-content: flex-start; vertical-align:middle;" @tap="openEdit(item)">
				<view v-if="item.photo" style="margin-left: 30rpx;" class="cu-avatar round lg" :style="[{ backgroundImage:'url(' + item.photo + ')' }]">
				</view>
				<view v-else class="round text-center" style="width: 96rpx;height: 96rpx;line-height: 100rpx;background-color: #E4F3FF;margin-left: 30rpx;">
					<text style="color: #B1D0E9;font-size: 90rpx;" class="iconfont icon-jiatingchengyuanmorentouxiang"></text>
				</view>
				<view>
				<view style="font-size: 28rpx;padding: 20rpx 30rpx 0 30rpx;"><text>{{item.fullName}}</text></view>
				<view class="content text-gray text-sm">
					<text>{{item.cardTypeName}}：{{item.idcard}}</text>
				</view>
				<view class="content text-gray text-sm">
					<text>他（她）是本人的：{{item.holderRelationName}}</text>
				</view>
				</view>
			</view>
		</view>
		<view v-if="memberList.length===0" class="text-center" style="padding-top: 200rpx;" @tap="openAdd">
			<image style="width: 310rpx;height: 216rpx;" src="/static/iconfont/no_family_list.png"></image>
			<view class="text-gray">添加家庭成员信息</view>
		</view>
		<view class="cu-bar foot-zh" style="height: 110rpx;padding-right:0rpx">
			<view style="padding: 0 30rpx 0 30rpx;width: 100%;" class="flex flex-direction " >
				<button class="cu-btn shadow margin-tb-sm lg bg-gradual-blue-light"  @tap="openAdd"><text class="iconfont icon-jia" style="padding-right: 20rpx;"></text>添加</button>
			</view>
		</view>
	</view>
</template>

<script>
	import store from "@/store"
	import api from '@/api/system/familyMember.js'
	export default {
		onShow() {
			this.headerKey += 1;
			this.getList()
		},
		data() {
			return {
				headerKey:0,
				personId:store.state.hh_user.personId,
				memberList:[]
			}
		},
		methods: {
			getList(){
				const data ={}
				data.masterId = this.personId
				this.$http.post(api.getListByMasterId, data).then(res => {
					this.memberList = res.result
				}).catch(error => {
						
				})
			},
			openAdd(){
				const params = {}
				params.funcType='add'
				this.$Router.push({ path:'/pages/system/user/memberDetail',query:params})
			},
			openEdit(item){
				const params = {}
				params.funcType='edit'
				params.memberId=item.memberId
				this.$Router.push({ path:'/pages/system/user/memberDetail',query:params})
			}
		}
	}
</script>

<style lang="scss">

</style>
